package com.teamone.etl.taskmanager.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 数据关联表(EtlTaskJoinInfo)表实体类

 @author makejava
 @since 2021-01-09 08:46:32 */
@SuppressWarnings("serial")
public class EtlTaskJoinInfo extends Model<EtlTaskJoinInfo> {
    /**
     id
     */
    @TableId(type = IdType.INPUT)
    private String id;
    /**
     节点ID
     */
    private String nodeId;
    /**
     任务ID
     */
    private String taskId;
    /**
     左节点ID
     */
    private String leftNodeId;
    /**
     左表ID
     */
    private String leftId;
    /**
     关联方式
     */
    private String joinType;
    /**
     右表节点ID
     */
    private String rightNodeId;
    /**
     右表ID
     */
    private String rightId;
    /**
     左表字段
     */
    private String leftJoinField;
    /**
     右表字段
     */
    private String rightJoinField;
    /**
     乐观锁
     */
    private Integer revision;
    /**
     创建人
     */
    private String createBy;
    /**
     创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;
    /**
     更新人
     */
    private String updateBy;
    /**
     更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    public EtlTaskJoinInfo(JSONObject node, Date now, String leftId, String rightId) {
        this.id=UUID.randomUUID().toString();
        this.nodeId=node.getString("id") ;
        JSONObject nodeData = node.getJSONObject("data");
        JSONArray fromNodeData = nodeData.getJSONArray("fromNodeData");
        JSONObject left = fromNodeData.getJSONObject(0);
        JSONObject right = fromNodeData.getJSONObject(1);
        this.taskId=nodeData.getString("taskId");
        this.leftId=leftId;
        this.leftNodeId=left.getString("id");
        this.rightId=rightId;
        this.rightNodeId=right.getString("id");
        this.joinType=nodeData.getString("joinType");
        this.leftJoinField=nodeData.getString("leftJoinField");
        this.rightJoinField=nodeData.getString("rightJoinField");
        this.createTime=this.updateTime=now;
    }


    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getNodeId () {
        return nodeId;
    }

    public void setNodeId (String nodeId) {
        this.nodeId = nodeId;
    }

    public String getTaskId () {
        return taskId;
    }

    public void setTaskId (String taskId) {
        this.taskId = taskId;
    }

    public String getLeftNodeId () {
        return leftNodeId;
    }

    public void setLeftNodeId (String leftNodeId) {
        this.leftNodeId = leftNodeId;
    }

    public String getLeftId () {
        return leftId;
    }

    public void setLeftId (String leftId) {
        this.leftId = leftId;
    }

    public String getJoinType () {
        return joinType;
    }

    public void setJoinType (String joinType) {
        this.joinType = joinType;
    }

    public String getRightNodeId () {
        return rightNodeId;
    }

    public void setRightNodeId (String rightNodeId) {
        this.rightNodeId = rightNodeId;
    }

    public String getRightId () {
        return rightId;
    }

    public void setRightId (String rightId) {
        this.rightId = rightId;
    }

    public String getLeftJoinField () {
        return leftJoinField;
    }

    public void setLeftJoinField (String leftJoinField) {
        this.leftJoinField = leftJoinField;
    }

    public String getRightJoinField () {
        return rightJoinField;
    }

    public void setRightJoinField (String rightJoinField) {
        this.rightJoinField = rightJoinField;
    }

    public Integer getRevision () {
        return revision;
    }

    public void setRevision (Integer revision) {
        this.revision = revision;
    }

    public String getCreateBy () {
        return createBy;
    }

    public void setCreateBy (String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime () {
        return createTime;
    }

    public void setCreateTime (Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy () {
        return updateBy;
    }

    public void setUpdateBy (String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime () {
        return updateTime;
    }

    public void setUpdateTime (Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     获取主键值

     @return 主键值
     */
    @Override
    protected Serializable pkVal () {
        return this.id;
    }
}